In rectangle $ABCD,$ $P$ is a point on side $\overline{BC}$ such that $BP = 16$ and $CP = 8.$  If $\tan \angle APD = 3,$ then find $AB.$
Let $Q$ be the projection of $P$ onto $\overline{AD},$ and let $x = AB = PQ.$

[asy]
unitsize(1.5 cm);

pair A, B, C, D, P, Q;

A = (0,0);
B = (0,2);
C = (3,2);
D = (3,0);
P = (2,2);
Q = (2,0);

draw(A--B--C--D--cycle);
draw(A--P--D);
draw(P--Q);

label("$A$", A, SW);
label("$B$", B, NW);
label("$C$", C, NE);
label("$D$", D, SE);
label("$P$", P, N);
label("$Q$", Q, S);
label("$16$", (B + P)/2, N);
label("$8$", (C + P)/2, N);
label("$16$", (A + Q)/2, S);
label("$8$", (D + Q)/2, S);
label("$x$", (A + B)/2, W);
label("$x$", (P + Q)/2, W);
[/asy]

Then from right triangle $APQ,$
\[\tan \angle APQ = \frac{16}{x}.\]From right triangle $DPQ,$
\[\tan \angle DPQ = \frac{8}{x}.\]Then
\begin{align*}
\tan \angle APD &= \tan (\angle APQ + \angle DPQ) \\
&= \frac{\tan \angle APQ + \tan \angle DPQ}{1 - \tan \angle APQ \cdot \tan \angle DPQ} \\
&= \frac{\frac{16}{x} + \frac{8}{x}}{1 - \frac{16}{x} \cdot \frac{8}{x}} \\
&= \frac{24x}{x^2 - 128} = 3.
\end{align*}Hence, $x^2 - 128 = 8x,$ or $x^2 - 8x - 128 = 0.$  This factors as $(x - 16)(x + 8) = 0,$ so $x = \boxed{16}.$